const log = require('../util/log')

module.exports = (req, res) => {
  require('../util/service').handlePost(req, res, (reqObj, resolve) => {
    if (!reqObj.channelId) {
      resolve({
        result: -1,
        msg: '缺少channelId'
      })
    }
    req.session.customer.baiduPushChannelId = reqObj.channelId
    if (['18820005776', '13632194032'].indexOf(req.session.customer.phone) != -1) {
      require('../util/BaiduPush')({
        apikey: 'XjZGXnn0WFEZeGUWISyzajbA',
        secretKey: 'hKtejZbXGNsUtcyXwzj49dsZvAi5jhcT'
      }).tagAddDevices({
        tag: 'admin',
        channel_ids: [reqObj.channelId]
      }).then(result => {
        log(result)
      }, result => {
        log(result)
      })
    }
    resolve({
      result: 1
    })
  })
}
